package cn.sxt.common.shop.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Component;

/**
 * 日期转换工具类
 * @author Administrator
 *
 */
@Component("dateFormatUtil")
public class DateFormatUtil {
	private String formatDateTime = ConstantFinalUtil.CONFIG_JSON.getString("formatDateTime");
	private String formatDate = ConstantFinalUtil.CONFIG_JSON.getString("formatDate");
	/**
	 * 字符串转日期
	 * @param str
	 * @return
	 */
	public Date parseDateTime(String str){
		SimpleDateFormat sdf = new SimpleDateFormat(formatDateTime);
		try {
			return sdf.parse(str);
		} catch (ParseException e) {
		}
		return null;
	}
	public String formatDateTime(Date nowDate){
		SimpleDateFormat sdf = new SimpleDateFormat(formatDateTime);
		return sdf.format(nowDate);
	}
}
